package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(com.atguigu.lease.common.exception.LeaseException.class)
    @ResponseBody
    public Result error(com.atguigu.lease.common.exception.LeaseException e){
        e.printStackTrace();
        return Result.fail( e.getMessage(),e.getCode());
    }








    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){

        e.printStackTrace();
        return Result.fail();
    }
}